package com.example.springsecurity.auth.qq.connet;

        import com.example.springsecurity.auth.qq.api.QQ;
        import com.example.springsecurity.auth.qq.api.QQImpl;
        import org.springframework.social.oauth2.AbstractOAuth2ServiceProvider;
        import org.springframework.social.oauth2.OAuth2Operations;
        import org.springframework.social.oauth2.OAuth2Template;

/**
 * 构建serviceProvider
 */
public class QQServiceProvider extends AbstractOAuth2ServiceProvider<QQ> {

    private String appId;

    //将用户导向认证服务器的url
    private static final String URL_AUTHORIZE = "https://graph.qq.com/oauth2.0/authorize";
    //获取token的url
    private static final String URL_ACCESS_TOKEN = "https://graph.qq.com/oauth2.0/token";

    public QQServiceProvider(String appId,String appSecret) {
        // 先利用springsocial提供的OAuth2Operation实现类-->OAuth2Template走OAuth2协议的步骤(但有一点问题)
        super(new OAuth2Template(appId,appSecret,URL_AUTHORIZE,URL_ACCESS_TOKEN));
        this.appId = appId;//***************
    }

    @Override
    public QQ getApi(String accessToken) {
        return new QQImpl(accessToken,appId);
    }
}
